package com.ls.controller;

import com.ls.pojo.Employee;
import com.ls.resultvo.Result;
import com.ls.service.EmployeeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/crm")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @PostMapping("/add")
    public String test1(@RequestBody Employee emp) {
        employeeService.save(emp);
        return "ok";
    }

    @PostMapping("/del/{id}")
    public String test2(@PathVariable(value = "id", required = true) Integer id) {
        employeeService.removeById(id);
        return "ok";
    }


    @PostMapping("/update")
    public String test3(@RequestBody Employee emp) {
        employeeService.updateById(emp);
        return "ok";
    }


    @GetMapping("/all")
    public Result<List<Employee>> test4() {
        return Result.ok(employeeService.list());
    }


}
